import sysMsgApi from '@/api/msg-manage/sys-msg'

const sysMsg = {
  state: {
    count: 0
  },
  mutations: {
    SET_MSG_COUNT: (state, count) => {
      state.count = count
    }
  },
  actions: {
    setMsgCount({ commit }, count) {
      commit('SET_MSG_COUNT', count || 0)
    },

    getMsgCount({ commit }) {
      // sysMsgApi.getNoReadCount({}).then(resp => {
      //   commit('SET_MSG_COUNT', resp.data || 0)
      // }).catch(resp => {
      //   // this.listLoading = false
      //   // this.$message.error(resp.message)
      // })
      return new Promise((resolve, reject) => {
        sysMsgApi.getNoReadCount({}).then(resp => {
          commit('SET_MSG_COUNT', resp.data || 0)
          resolve(resp)
        }).catch(resp => {
          reject(resp)
        })
      })
    }
  }
}

export default sysMsg
